Home

Operator Usage

Name

substring-position

Description

substring-position(|substring>) input-seq
return the substring positions of "substring" for all kets in the input sequence
if the substring is not in a ket, then we return the empty ket |>
positions start at 1, not 0
if you just want to know if a substring is in the given input, then apply the do-you-know operator
if the parameter is more than one ket, merge all the positions together, probably don't want this!


Examples

-- simple check if the substring "beta" is in the given ket:
substring-position(|beta>) |alpha beta gamma>
    |7>

-- simple check if the substring "delta" is in the given ket:
substring-position(|delta>) |alpha beta gamma>
    |>

-- once again, this time using do-you-know:
do-you-know substring-position(|delta>) |alpha beta gamma>
    |no>

-- now applied to a toy sequence:
substring-position(|beta>) ssplit[" "] |alpha beta gamma>
    |> . |1> . |>

-- another toy sequence, this time demonstrating multiple matches per ket:
substring-position(|a>) ssplit[" "] |alpha beta gamma>
    |1> + |5> . |4> . |2> + |5>


See also

Operator type

function 1